function wi=self_adapted_weight(num)
%clc
%clear all
%num = xlsread('data\score');
aij=num;
[ilength,jlength]=size(num);
wi=zeros(1,ilength);
aj_history=[];
wi_history=[];
for i=1:ilength
    wi(i)=round(1/ilength,4);
end
w0=wi;
wi_history=[wi_history;wi];
flag =1;
while flag==1
    for j=1:jlength
        num(:,j)=wi'.*aij(:,j);
    end
    aj=sum(num,1);
    aj_history=[aj_history;aj];
    S=zeros(1,ilength);
    for i=1:ilength 
        S(i)=sqrt(sum((aij(i,:)-aj).^2));
    end
    a=sum(S);
    fx=zeros(1,length(S));
    if a~=0
        for i=1:length(S)
            if S(i)~=0
                fx(i)=-1/log(S(i)/a);
            end
        end
    end
    Ri=zeros(1,length(S));
    fx_s=sum(fx);
    if fx_s~=0
        for i=1:length(S)
            if fx(i)~=0
                Ri(i)=fx(i)/fx_s;
            end
        end
    end
    gx=zeros(1,length(S));
    gx_s=0;
    for i=1:length(S)
        if fx(i)~=0
            gx(i)=1/(exp(Ri(i))-1);
            gx_s=gx_s+gx(i);
        else
            gx(i)=inf;
        end
    end

    miui=zeros(1,length(S));

    for i=1:length(S)
        if fx(i)~=0
            miui(i)=gx(i)/gx_s;
        else
            miui(i)=inf;
        end
    end
    wii=round(w0.*miui/sum(w0.*miui),4);
    if all(wii(:)==wi(:))
        flag=0;%直到前后的权重相同则停止迭代
    end
    wi=wii
    wi_history=[wi_history;wi];
end
end